﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using ThirdServices.AlertModel.Factory.Entities.DTO;
using ThirdServices.WindSettings;

namespace ThirdServices.AlertModel.Analyzers
{
    class WindAnalyser
    {
        public static List<BaseAlert> AnalyseWindData(List<WindSpeedData> windSpeedData)
        {
            List<BaseAlert> baseAlerts = new List<BaseAlert>();
            foreach (WindSpeedData wsd in windSpeedData)
            {
                foreach(WindTypeElement windType in Settings.WindSettings.WindTypes)
                {
                    if (wsd.Speed < windType.Max)
                    {
                        if (windType.BofortScale >= Settings.WindSettings.CriticalWindType.BofortScale)
                        {
                            baseAlerts.Add(new BaseAlert
                                               {
                                                   NotificationDescription = new NotificationDescription
                                                                                 {
                                                                                     alert_type = AlertTypes.WindAlert,
                                                                                     notification = Convert.ToString(wsd.Speed,CultureInfo.InvariantCulture)
                                                                                 }
                                               });
                        }
                        break;
                    }
                }
            }
            return  baseAlerts;
        }
    }
}
